package controllers

type RespCode int64

const (
	CodeSuccess RespCode = 10000 + iota
	CodeError
	CodeInvalidParam
	CodeUsernameExist
	CodeLoginError
	CodeSignUpError
	CodeSystemBusy
	CodeNotToken
	CodeInvalidToken
	CodeNeedLogin
)

var codeMsgMap = map[RespCode]string{
	CodeSuccess:       "success",
	CodeError:"操作错误",
	CodeInvalidParam:  "参数错误",
	CodeUsernameExist: "用户名已存在",
	CodeSignUpError:   "注册失败",
	CodeLoginError:    "用户名或密码错误",
	CodeSystemBusy:    "系统繁忙",
	CodeNotToken:      "token不能为空",
	CodeInvalidToken:  "无效的token",
	CodeNeedLogin:     "登录过期，请重新登录",
}

func (c RespCode) getMsg() string {
	msg, ok := codeMsgMap[c]
	if !ok {
		msg = codeMsgMap[CodeSystemBusy]
	}
	return msg
}
